﻿Public Class FrmCountDown
    ' Dim MuteTime As Integer = 10   ' gone public 
    Dim PreviousVolume As Integer
    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        If MuteTime > 1 Then
            Form1.Player.settings.volume = MuteLevel
            MuteTime = MuteTime - 1
        Else
            MuteTime = objIniFile.GetString("settings", "mutetime", 10)
            Timer1.Enabled = False
            Form1.Player.settings.volume = PreviousVolume
            Me.Close()

        End If
        Label1.Text = MuteTime

    End Sub

    Private Sub FrmCountDown_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
        Form1.Player.settings.volume = PreviousVolume
    End Sub

    Private Sub FormCountDown_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.Top = Screen.PrimaryScreen.WorkingArea.Height / 2 - Me.Height / 2
        Me.Left = Screen.PrimaryScreen.WorkingArea.Width / 2 - Me.Width / 2
        If MuteTime > 0 Then
            Label1.Text = MuteTime
            PreviousVolume = Form1.Player.settings.volume
            Form1.Player.settings.volume = MuteLevel
            Timer1.Enabled = True
        ElseIf MuteTime = 0 Then
            Label1.Text = "-"
            PreviousVolume = Form1.Player.settings.volume
            Form1.Player.settings.volume = MuteLevel
            Timer1.Enabled = False
            Form1.SendUnMute()
        End If


    End Sub

    Private Sub PictureBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox1.Click
        MuteTime = objIniFile.GetString("settings", "mutetime", 10)
        Timer1.Enabled = False
        Form1.Player.settings.volume = PreviousVolume
        Me.Close()
        Form1.SendUnmute()
    End Sub

    Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label1.Click
        MuteTime = objIniFile.GetString("settings", "mutetime", 10)
        Timer1.Enabled = False
        Form1.Player.settings.volume = PreviousVolume
        Me.Close()
        Form1.SendUnmute()
    End Sub
End Class